# Rock-paper-scissors-lizard-Spock template


# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors

# helper functions
import random

def number_to_name(number):
    # fill in your code below
    num2name={ 0:'rock',
              1: 'Spock',
              2: 'paper',
              3: 'lizard',
              4: 'scissors'};
    return num2name[number];
    # convert number to a name using if/elif/else
    # don't forget to return the result!

    
def name_to_number(name):
    # fill in your code below
    name2num={ 'rock': 0,
             'Spock' : 1,
             'paper' : 2,
             'lizard': 3,
             'scissors': 4};
    return name2num[name];

    # convert name to number using if/elif/else
    # don't forget to return the result!


def rpsls(name): 
    # fill in your code below

    # convert name to player_number using name_to_number
    plyr = name_to_number(name);
    # compute random guess for comp_number using random.randrange()
    com = random.randrange(0,5);
    # compute difference of player_number and comp_number modulo five
    mod = (plyr - com)% 5;
    print "player chooses %s" %(name);
    print "computer chooses %s" %(number_to_name(com));
    
    # use if/elif/else to determine winner
    if(mod == 1 or mod == 2):
        print "Player wins!\n";
    elif(mod == 3 or mod == 4):
        print "Computer wins!\n";
    else:
        print "It's draw!\n"
    # convert comp_number to name using number_to_name
    
    # print results

    
# test your code
rpsls("rock")
rpsls("Spock")
rpsls("paper")
rpsls("lizard")
rpsls("scissors")

# always remember to check your completed program against the grading rubric


